#!/usr/bin/python3
# -*-coding:utf-8 -*-

import subprocess
import sys
import utils

if __name__ == '__main__':
    if len(sys.argv) == 4:
        type = sys.argv[1]
        v = sys.argv[2]
        t = sys.argv[3]

        source = utils.pwd.joinpath("src").joinpath(utils.source(v))
        binary = utils.pwd.joinpath("bin").joinpath(utils.binary(v, t))

        cmd = 'echo \'hello world\''
        if type == 'omp':
            cmd = "g++ -std=c++17 -Wall -Wextra -fopenmp -DBEHCH_MARK_THREADS={t} -o {binary} {source}.cpp"
        elif type == 'cuda':
            cmd = "nvcc -o {binary} {source}.cu"
        elif type =='thread':
            cmd = "g++ -std=c++17 -Wall -Wextra -DBEHCH_MARK_THREADS={t} -o {binary} {source}.cpp -lpthread"
        elif type == "intel":
            cmd = "g++ -std=c++17 -Wall -Wextra -mavx2 -mavx512f -mavx512dq -fopenmp -DBEHCH_MARK_THREADS={t} -o {binary} {source}.cpp"
        else:
            cmd = "g++ -std=c++17 -Wall -Wextra -o {binary} {source}.cpp"
        cmd = cmd.format(binary=binary, source=source, t=t)
        print(cmd)
        
        subprocess.call(cmd, shell=True)
    else:
        print(__file__, "<type>", "<v>", "<t>")
        pass